#!/usr/bin/env python
# -*- coding:UTF-8 -*-
"""
composite.py
"""
from abc import ABCMeta, abstractmethod

class Component(object):
    __metaclass__ = ABCMeta

    def __init__(self, name): self._name = name

    def show(self, level): print('{}{}'.format('-' * level, self._name))

    @abstractmethod
    def add(self, c): pass

    @abstractmethod
    def remove(self, c): pass


class Composite(Component):
    def __init__(self, name):
        super().__init__(name)
        self.components = []

    def show(self, level):
        super().show(level)
        for c in self.components:
            c.show(level+1)

    def add(self, c): self.components.append(c)
    def remove(self, c): self.components.remove(c)


class Leaf(Component):
    def add(self, c): pass
    def remove(self, c): pass
